﻿using BaseData.DomainLib.AggregatesModel.WarehouseAggregate;
using Microsoft.EntityFrameworkCore;
using Swimj.DomainLib.SeedWork;

namespace BaseData.InfrastructureLib.Repositories;

public class WarehouseRepository : IWarehouseRepository
{
    private readonly BaseDataDbContext _baseDataDbContext;

    public IUnitOfWork UnitOfWork => _baseDataDbContext;

    public WarehouseRepository(BaseDataDbContext baseDataDbContext)
    {
        this._baseDataDbContext = baseDataDbContext;
    }

    public Warehouse Add(Warehouse warehouse)
    {
        return _baseDataDbContext.Warehouses.Add(warehouse).Entity;
    }

    public async Task<Warehouse?> Get(int id)
    {
        return await _baseDataDbContext.Warehouses.FirstOrDefaultAsync(i => i.Id == id);

    }
}